<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <img id="qrcode" src="" alt="" />
  <div id="code"></div>
  <script src="https://cdn.staticfile.org/jquery/3.3.1/jquery.min.js"></script>
  <script>
    getQrImage();
    function getQrImage() {
      $.ajax({
          type: "GET",
          url: "http://me.yofish.com:8090/getQrImage",
          dataType: "json",
          cache: !1,
          timeout: 6e4,
          success: function (data) {
           
            console.log(data);
            $('#qrcode').attr('src', data.results.imageBase64);
            var uuid = data.results.wxUUID;
            getCode(uuid);
          },
          error: function () {
            setTimeout(function () {
              window.location.reload();
            }, 2000)
          }
        })
    }

    function getCode(uuid, last) {
      $.ajax({
        type: "GET",
        url: "http://me.yofish.com:8090/getCode?uuid=" + uuid + (last ? '&last=' + last : ''),
        dataType: "json",
        cache: !1,
        timeout: 6e4,
        success: function (data) {
          
          if (data.status === 405) {
            $('#code').text('登陆成功，code = ' + data.result.code)
          } else if (data.status === 404) {
            $('#code').text(data.msg.title + ', ' + data.msg.content)
            getCode(uuid, data.result.wxErrCode)
          } else if (data.status === 403) {
            $('#code').text(data.msg.title + ', ' + data.msg.content)
            getCode(uuid, data.result.wxErrCode)
          } else if (data.status === 500) {
            getUUID()
          } else {
            setTimeout(function () {
              getCode(uuid)
            }, 2000)
          }
        },
        error: function () {
          setTimeout(function () {
            // window.location.reload();
            // getCode(uuid)
          }, 2000)
        }
      })
    }
  </script>
</body>
</html>